﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.util.*"%>
<%@page import="com.mtbu.comm.Util"%>
<%@page import="com.mtbu.bean.*"%>
<%@page import="com.mtbu.dao.*"%>
<%@page import="my.myorm.tool.jdbc.*"%>
<%@page import="my.tool.ConfigProp" %>

<%@include file="sys_commcheck.jsp"%>



<%!
	public String createStateWord(int state){

		if(1 == state) return "<font color=\"#0033FF\">正常</font>";
		if(2 == state) return "<font color=\"#ff3300\">异常</font>";
		return "<font color=\"#999999\">未知</font>";
	}
%>


<%
    String curFile = SuperPage.getCurURLFile(request);

	//System.out.println("curFile:" + curFile);
	//System.out.println("request:" + request.getRequestURI());

	String modFile = SuperFile.getFileName(curFile) + "mod.jsp";
	String readFile = SuperFile.getFileName(curFile) + "read.jsp";
	String modFileDo = SuperFile.getFileName(curFile) + "moddo.jsp";
	String viewFile = SuperFile.getFileName(curFile) + "view.jsp";



    String id=SuperString.notNullTrim(request.getParameter("id"));
	String pid=SuperString.notNullTrim(request.getParameter("pid"));
	Project project = DAOManager.projectDao.findProject(pid);
    int s_pagesize=SuperString.getInt(request.getParameter("s_pagesize"));
	String curName = "STEP列表" + "-" + project.getName();

    String dropparam="pid,id,s_status,s_pagesize,issearch";

    if(request.getMethod().equalsIgnoreCase("post")){
        StringBuffer sbparam=new StringBuffer();
        sbparam.append("&issearch=1");
		if(s_pagesize>0) sbparam.append("&s_pagesize=").append(s_pagesize);


        if(!"".equals(id)) sbparam.append("&id=").append(Util.encodeUrl(id));
		if(!"".equals(pid)) sbparam.append("&pid=").append(Util.encodeUrl(pid));

        String strparam=sbparam.toString();
        if(strparam.startsWith("&")) strparam="?"+strparam.substring(1);
        strparam+="".equals(strparam)? SuperPage.getQueryQ(request,dropparam): SuperPage.getQueryAnd(request,dropparam);

		//System.out.println("search:" + curFile+strparam);

        response.sendRedirect(curFile+strparam);
        return;
    }


    //组合条件
    StringBuffer strw = new StringBuffer();

    if(!"".equals(id)) strw.append(" and id like '%").append(id).append("%' ");
	if(!"".equals(pid)) strw.append(" and projectid = '").append(pid).append("' ");

    String strwhere = Util.getWhereSQL(strw);
	//System.out.println("sql:" + strwhere);

    String order = SuperString.notNullTrim(request.getParameter("order"));
    String orderby = order.length() == 0 ? " order by id desc" :
            " order by " + order;

    SQLExecutor dbconn = SQLManager.getSQLExecutor();
    String sql = "select * from step "+ strwhere + orderby;
	System.out.println("sql:" + sql);
    int pagesize=Util.getPageSizeOfCookie(request,response,s_pagesize);
    Pages pages = new Pages(pagesize, "id", request);
    ResultList rs =dbconn.query(sql,false,pages);

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=curName%></title>
<link href="css/common.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/comm.js"></script>
<script language="javascript" src="js/tablecell.js"></script>
<script type="text/javascript" src="js/jquery.js" language="javascript"></script>
<script type="text/javascript" src="js/comm_confirm.js" language="javascript"></script>
<script type="text/javascript" src="js/pbx_tips.js" language="javascript"></script>
<style type="text/css">
a{
	text-decoration:none;
	color:#f30;
}
img{border:none;}
</style>
<script type="text/javascript">
var selall=false;
function allselect(){
    selall=!selall;
    var checks=document.getElementsByName("check_id");
    if(checks==null||checks==undefined) return;
    for(var i=0;i<checks.length;i++){
        checks[i].checked=selall;
    }
}
function batchIn(){
    var ids="";
    var checks=document.getElementsByName("check_id");
    if(checks==null||checks==undefined) return;
    for(var i=0;i<checks.length;i++){
        if(checks[i].checked){
           ids+=","+checks[i].value;
        }
    }
    window.location.href="bpp_channel_in_batchmod.jsp?act=batchin&ids="+ids;
}



</script>
</head>

<body onload="move()" onmousemove="canMove()" >
<div class="title_text"><%=curName%></div>
<fieldset class="order_fieldset">
    <legend>输入查询条件</legend>
    <table width="100%"  border="0" cellspacing="1" cellpadding="2" style="margin:5px 0;">
      <form name="form_s" action="<%=curFile%><%=SuperPage.getQueryQ(request,dropparam)%>" method="post" class="formline">
        <tr>
          <td >
		  	ID
		    <input name="id" type="text" id="id" title="ID" value="<%=id%>" maxlength="30">
			<!-- 项目ID -->
		   <input name="pid" type="hidden" id="pid" title="ID" value="<%=pid%>" maxlength="30">
          <td width="9%" align="right">&nbsp;</td>
        </tr>
		<tr>
          <td >
            每页显示
            <input name="s_pagesize" type="text" id="s_pagesize" title="每页显示" value="<%=s_pagesize>0?s_pagesize:""%>" size="2" maxlength="6">
            <input name="Submit2" type="submit" class="BUTTON3" value=" 搜索 ">
		  </td>
          <td width="9%" align="right">&nbsp;</td>
        </tr>
      </form>
    </table>
</fieldset>
<div style="height:2px;"><span/></div>


<div class="page_nav00">
<span class="page_search">页内查找:<input type="text" id="filterPageIpt" onkeyup="filtePage()" class="modinput"></span>
<span><input type="button" onclick="location.href='<%=modFile+"?pid="+pid %>'" value=" 增加" class="BUTTON3" name="Submit"></span>
</div>
<table id="table_data" width="100%" border="0" cellpadding="1" cellspacing="1" class="table_bord">
  <tr class="table_bord_ttl">
    <td onClick="title_click('<%=Util.getOrderUrl("id",order,request)%>')">ID<%=Util.getOrderByImgHTML("id",order)%></td>
	<td onClick="title_click('<%=Util.getOrderUrl("projectid",order,request)%>')">项目ID<%=Util.getOrderByImgHTML("projectid",order)%></td>
	<td onClick="title_click('<%=Util.getOrderUrl("name",order,request)%>')">名称 <%=Util.getOrderByImgHTML("name",order)%></td>
	<td onClick="title_click('<%=Util.getOrderUrl("type",order,request)%>')">类型 <%=Util.getOrderByImgHTML("type",order)%></td>
	<td onClick="title_click('<%=Util.getOrderUrl("beanname",order,request)%>')">执行Bean<%=Util.getOrderByImgHTML("beanname",order)%></td>
	<td onClick="title_click('<%=Util.getOrderUrl("prestepid",order,request)%>')">上一步<%=Util.getOrderByImgHTML("prestepid",order)%></td>
	<td onClick="title_click('<%=Util.getOrderUrl("nextstepid",order,request)%>')">下一步<%=Util.getOrderByImgHTML("nextstepid",order)%></td>
	<td onClick="title_click('<%=Util.getOrderUrl("updatetime",order,request)%>')">更新时间<%=Util.getOrderByImgHTML("updatetime",order)%></td>
    <td >操作</td>
  </tr>
<%
	String[] _status = new String[]{"normal","locked"};
	String[] _type_status = new String[]{"默认","自有"};
	String[] _statuscolors = new String[]{"#0033FF","#999999"};
    for(int i = 0; i < rs.size(); i++) {
    	Step record= rs.get(i).get(Step.class);
        String trclass = i % 2 == 0 ? "tr_class1" : "tr_class2";
%>
  <tr name="datatr" class="<%=trclass%>" onMouseMove="cell_over(this);" onMouseOut="cell_out(this)" onClick="cell_click(this);" height="20">
    <td><%=record.getId()%></td>
	<td><%=record.getProjectId()%></td>
	<td><%=record.getName()%></td>
	<td><%=record.getType()%></td>
	<td><%=record.getBeanName()%></td>
	<td><%=record.getPreStepId()%></td>
	<td><%=record.getNextStepId()%></td>
	<td title="<%=record.getUpdateTime_ToDateTimeString()%>" ><%=record.getUpdateTime_ToDateString()%></td>
    <td>
		<a href="<%=modFile%>?act=mod&id=<%=record.getId()%><%=SuperPage.getQueryAnd(request,"act,id,s_pid,pid")%>">修改</a>
		|<a href="<%=modFileDo%>?act=del&id=<%=record.getId()%><%=SuperPage.getQueryAnd(request,"act,id,s_pid,pid")%>">删除</a>
	</td>

  </tr>
<%
    }
    if(rs.size()==0){
%>
  <tr bgcolor="#FFFFFF">
    <td height="50" colspan="20" align="center">没有数据</td>
  </tr>
  <%
    }
%>
</table>
    <div class="page_nav00">
   </div>
  <div class="page_nav00"><%=SuperPage.generatePageNavSingle(rs.getAllCount(), request, null, pages.getPageSize(),"个")%></div>
<div style="height:30px;">

</div>
<script type="text/javascript">
$("body").children().not($("#table_data")).click(function(){cancelAllChecked();});
filtePage();
</script>
<%@include file="sys_commfooter.jsp"%>
</body>
</html>